<template>
    <div>
    <el-container class="form-container">
        <el-card class="box-card" shadow="never">
            <div slot="header" class="clearfix">
                <span>基本信息</span>
                <el-button type="primary" size="mini" style="float:right;padding: 6px 9px;" @click="handlerSubmitForm">保存</el-button>
            </div>
            <div >
                <el-form  :rules="rules"  ref="form"  :model="form" size="small" label-width="120px">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item  label="名称"  prop="fdName">
                                <el-input class="input" v-model="form.fdName"  ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item  label="编号"  prop="fdNo">
                                <el-input class="input" v-model="form.fdNo"  ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                        <el-form-item  label="上级部门"  prop="fdParentName">
                                <fancy-address v-model="form.fdParentName" :id.sync="form.fdParentId"  orgType="ORG|DEPT" @onValueChange="setDept" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                        <el-form-item  label="是否有效" prop="fdIsAvaliable">
                            <el-switch v-model="form.fdIsAvaliable"/>
                        </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item  label="排序号"  prop="fdOrder">
                                <el-input-number v-model="form.fdOrder" :min="0"  label="排序号"></el-input-number>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
        </el-card>
    </el-container>
</div>
</template>
<script>
import {edit,parentEdit} from '@/components/mixins/form'
export default {
    name: "sysOrgDeptAdd",
    components: {
    },
    data() {
        return {
            updateUrl:'/api/sys/org/sys_org_dept',
            fetchUrl:'/api/sys/org/sys_org_dept',
            fetchParentUrl:'/api/sys/org/sys_org_dept',
            form: {
                fdOrder:'',
                fdLeaderName:'',
                fdParentId:'',
                fdParentOrgId:'',
                fdParentOrgName:'',
                fdParentName:'',
                fdLeaderId:'',
                fdNo:'',
                fdName:'',
                fdIsAvaliable:true,
                fdId:''
            },
            rules:{
              fdName :[{required: true, message: '请输入名称', trigger: 'blur'}]
            }
        }
    },
    mixins:[edit,parentEdit],
    methods: {
        setDept(obj){
         if(obj.id !== ''){
           this.form.fdParentOrgId = '';
           this.form.fdParentOrgName = '';
         } 
        },
        setOrg(obj){
         if(obj.id !== ''){
           this.form.fdParentId = '';
           this.form.fdParentName = '';
         } 
        }
    }
}
</script>
<style scoped >
@import "~@/assets/css/form.css";
</style>